<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class Adminrecord_model extends CI_Model {
	public function __construct() {
		parent::__construct ();
	}
	/*
	 * 记得管理员登录信息
	 */
	public function create($adminrecord){
		$this->db->insert('t_adminrecord', $adminrecord);
		return $this->db->insert_id();
	}
	/*
	 *根据分页信息得到管理员登录记录
	 */
	public function find_all_records($per_page,$offset){//
		$this->db->select('t_adminrecord.id,t_admin.name as name,t_adminrecord.login_time');
		$this->db->from('t_adminrecord');
		$this->db->join('t_admin', 't_admin.id = t_adminrecord.adminid','left');
		$this->db->limit($per_page, $offset);
		$this->db->order_by("login_time", "desc");
		$query = $this->db->get();
		return $query->result_array();
	}
	/*
	 * 返回管理员登录记录数量
	 */
	public function count_records(){
		$query = $this->db->get('t_adminrecord');
		return $query->num_rows();
	}
}
